//
// city
//
(function(){
	var _p = P('sango.city'),
		_city_prop_template = '{0}:<input type="text" name="{0}" value="{1}"/><br/>';

	_p.init = function() {
		$('#btn_create_city').click(_p._create_city);
		// setup city prototype
		U.get_json('/sango/city/proto', null, function(_proto){
			var _prop, _def;
			for(_prop in _proto) {
				_def = _proto[_prop];
				$('#city_form').prepend(_city_prop_template.format([_prop,_def]));
			}
		});
	};

	_p._create_city = function() {
		var _city = U.make_bean($('#city_form input'));
		U.post_json('/sango/city/add', _city, function(_s){alert(_s);});
	};

})();

